# 添加元素
fruits = {"apple", "banana", "cherry"}
fruits.add("orange")
print(fruits)

# 复制集合
x = fruits.copy()
print(x)

# 去除集合中相同的元素并返回一个新集合
x = {"apple", "banana", "cherry"}
y = {"google", "microsoft", "apple"}
z = x.difference(y)
print(z)

# 在原集合x中删除与集合 y 相同的元素
x = {"apple", "banana", "cherry"}
y = {"google", "microsoft", "apple"}
x.difference_update(y)
print(x)

# 删除集合中指定元素
fruits = {"apple", "banana", "cherry"}
fruits.discard("banana")
print(fruits)

# 获取两个集合的交集
x = {"apple", "banana", "cherry"}
y = {"google", "microsoft", "apple"}
z = x.intersection(y)
print(z)

#  在原集合x中保留与集合 y 相同的元素
x = {"a", "b", "c"}
y = {"c", "d", "e"}
z = {"f", "g", "c"}
x.intersection_update(y, z)
print(x)


